/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package game.experts.combine;

import game.encodings.OutputEncoding;
import game.experts.ground.wrappers.AlignmentExpert;
import java.util.HashMap;
import utils.ArrayUtils;
import utils.Profile;
import utils.ProfileMatrix;
import utils.configuration.PercentageValueHolder;

/**
 *
 * @author emanuele
 */
public class SSPHybridAlignmentHintedCombinerExpert extends SSPBaseHintedCombinerExpert {
    public PercentageValueHolder averagingWeight = new PercentageValueHolder(0.01);

    @Override
    public HashMap<String, Object> getOptions() {
        averagingWeight.setDescription("The weight associated to the averaging method with respect to the alignment method.");
        final HashMap<String, Object> options = super.getOptions();

        options.remove("weightExpression");

        return options;
    }

    @Override
    protected Profile mergePredictions(OutputEncoding[] allPredictions) {
        AlignmentExpert alexp = new AlignmentExpert();
        alexp.minEvalue = this.minevalueth;
        alexp.totalAligned = this.maxhints;

        Profile ali = alexp.interrogate(this.current.input);

        AveragingCombinerExpert avexp = new AveragingCombinerExpert();
        avexp.setExperts(this.getExperts());

        Profile ave = avexp.mergePredictions(allPredictions);

        Profile ret;

        ret = new ProfileMatrix(3, this.current.input.length(), 0);

        for (int col = 0; col < ret.length(); col++) {
            ret.setColumn(col,
                    ArrayUtils.sumTo(ArrayUtils.mulBy(ali.getColumn(col), 1),
                                     ArrayUtils.mulBy(ave.getColumn(col), this.averagingWeight.getValue())));
        }

        ret.normalizeColumns();

        return ret;
    }

}
